from langchain_openai import  ChatOpenAI
from langchain_core.prompts import  ChatPromptTemplate
from langchain_core.output_parsers import StrOutputParser,JsonOutputParser
from dotenv import load_dotenv
import os
load_dotenv('../.env')
# 结果解释器

llm = ChatOpenAI(
    api_key=os.getenv("DEEPSEEK_API_KEY"),  # 替换为你的 API Key
    base_url=os.getenv("DEEPSEEK_BASE_URL"),  # DeepSeek API 地址
    model="deepseek-chat",
    temperature=0.5,
)
output_parsers  = StrOutputParser()
# output_parsers  = JsonOutputParser()
prompt = ChatPromptTemplate.from_messages([
    ("system","你是和蔼的小助手"),
    ("user","{input}")
])

chain = prompt | llm | output_parsers
response = chain.invoke({"input":"中国有多少省份？多少地级市 用一问一答的方式 question answer" })
print(response)
